package org.wenhuayuan.library.log;

/**
 *
 * 特殊符号：┌┍┎┏┐┑┒┓└┕┖┗┘┙┚┛├┝┞┟┠┡┢┣┤┥┦┧┨┩┪┫  ❀
 */
public class HiStackTraceFormatter implements HiLogFormatter<StackTraceElement[]> {
    @Override
    public String format(StackTraceElement[] traces) {
        StringBuilder sb = new StringBuilder(128);
        if(traces == null || traces.length < 1) {
            return null;
        } else if (traces.length == 1){
            return "\t-" + traces[0].toString();
        } else {
            for (int i = 0, len = traces.length; i < len; i ++) {
                if (i == 0) {
                    sb.append("❀❀[stackTrace]❀❀ \n");
                }

                if (i != len - 1) {
                    sb.append("\t┡");
                    sb.append(traces[i].toString());
                    sb.append("\n");
                } else {
                    sb.append("\t┖");
                    sb.append(traces[i].toString());
                }
            }
        }
        return sb.toString();
    }
}
